# -*- coding:utf-8 -*-
# __author__ = 'HuangXiaoming'


import os
import tkinter.filedialog as fd
import tkinter.messagebox as mb
from tkinter import *
from CaseFormatter import BaseCaseFormatter


class CaseFormatterFrame:
    def __init__(self):
        self.frame = Frame(width=550, height=350)
        self.text = "案例格式化工具"
        self.help = "案例格式化工具说明"
        self.case_formatter = CaseFormatter()
        self.dir_var = StringVar()
        self.file_path = StringVar()
        self.set_frame()
        #self.var_xls.set('D:/WorkG/GenerateTestCasePy3/TestData/decision_table1.xls')
        #self.decision_table_to_case()

    # 选择xls文件
    def select_xls(self):
        absolute_path = fd.askopenfilename(initialdir=os.getcwd(), filetypes=[('xls files', '*.xls')])
        self.file_path.set(absolute_path)
        self.case_formatter.add_xls(absolute_path)

    def set_frame(self):
        # 标签
        Label(self.frame,text = 'excel文件:').place(x=30, y=90)
        # 输入框entry_txt
        entry_xls = Entry(self.frame, textvariable=self.file_path, width=43)
        entry_xls.place(x=120, y=90)
        # 按钮
        Button(self.frame, text='浏览', command=self.select_xls, height=1).place(x=490, y=85)
        Button(self.frame, text='格式化excel案例', command=self.case_formatter.execute).place(x=230, y=200)

class CaseFormatter(BaseCaseFormatter):
    def execute(self):
        super().execute(out_dir_mode="U")
        mb.showinfo(title="提示", message="格式化完成！")
